<?php

// show off: template
require_once("configuration.php");
require_once("includes/function.php");
require_once("includes/function.number.php");
require_once("includes/io.php");
require_once("includes/template.php");
require_once("includes/category.php");
require_once("includes/product.php");

$title = "Home";
$template = new template("default");

// variable initializationu
$page_id = isset($_GET['page']) ? intval(sql_injection($_GET['page'])) : 0;
$categories = "";
$product_rows = "";
$menu_rows = "";

// Navigator
require_once("includes/page.php");
require_once("includes/list.menu.php");

// required settings
require_once ("includes/setting.php");
$setting = new setting();
// PRODUCT SECTION
//$product = new Product();
//$product->limit = $setting->product_limit;
//$total_products = $product->get_total_products();
//// required pagination
//require_once ("includes/pagination.php");
//$pagination = new pagination("index.php?page=", $page_id, $total_products, $product->limit);
//// set the start to get products    
//$product->start = $pagination->start;
////$query_products = $product->get_products();
//$query_products = $product->get_topproduct(); //LPT select new product
//$pagination_html = $pagination->get_html();
//while ($obj = $mysql->fo($query_products)) {
//    $product = Product::static_set_object($obj);
//    if ($product->discount > 0) {
//        $discount_price = get_discount_price($product->price, $product->discount);
//        $product->price = "<del>{$product->price}$</del> {$discount_price}$";
//    } else {
//        $product->price = $product->price . "$";
//    }
//    eval("\$product_rows .= \"" . $template->get("product.rows") . "\";");
//}
//eval("\$products = \"" . $template->get("index.product") . "\";");

//load second product for 3 new products
$product = new Product();
$query_products = $product->get_threenewproduct(); //LPT select new product
while ($obj = $mysql->fo($query_products)) {
    $product = Product::static_set_object($obj);
   eval("\$product_rows .= \"" . $template->get("index.product.rows") . "\";");
}
eval("\$products = \"" . $template->get("index.product") . "\";");

//load second product for 3 new products
$news = new Product();
$query_news = $product->get_topnews(); //LPT select new product
while ($obj = $mysql->fo($query_news)) {
    $news = Product::static_set_object($obj);
}
eval("\$news = \"" . $template->get("news.rows") . "\";");

// Categories section
require_once("includes/list.categories.php");

// cart
require_once("includes/function.number.php");
require_once("includes/cart.php");
require_once("includes/list.cart.php");

// layout
eval("\$content = \"" . $template->get("index.content") . "\";");

eval("\$header = \"" . $template->get("header") . "\";");
eval("\$cart = \"" . $template->get("body.cart") . "\";");
eval("\$body = \"" . $template->get("body") . "\";");
eval("\$footer = \"" . $template->get("footer") . "\";");
eval("\$index = \"" . $template->get("index") . "\";");

//LPT Bring category sub to direct index pagr
eval("\$categoryRow = \"" . $template->get("category.rows") . "\";");
eval("\$categoryRowsChild = \"" . $template->get("category.rows.child") . "\";");
// display all
echo ($index); // can use echo $template->compress($index) to compress size of html

require_once("configuration.end.php");
?>